package cn.sptpc.service.impl;

import cn.sptpc.dao.DepartmentDao;
import cn.sptpc.dao.UserDao;
import cn.sptpc.dao.impl.DepartmentDaoI;
import cn.sptpc.dao.impl.UserDaoI;
import cn.sptpc.entity.web.JConsoleEntity;
import cn.sptpc.service.ConsoleService;
import com.google.gson.Gson;

public class ConsoleeServiceI implements ConsoleService {
    private DepartmentDao departmentDao = new DepartmentDaoI();
    private UserDao userDao = new UserDaoI();
    @Override
    public String infoMation() {
        Integer departmentCount = departmentDao.countAllDepartment();
        Integer userCount = userDao.queryCount();
        JConsoleEntity entity = new JConsoleEntity();
        Gson gson = new Gson();
        if (departmentCount==null && userCount == userCount){
            entity.setCode(1);
            return gson.toJson(entity);
        }
        entity.setActivityCount(0);
        entity.setUserCount(userCount);
        entity.setDepartmentCount(departmentCount);
        return gson.toJson(entity);
    }
}
